<?php

class Log
{
	public static function write($txt, $usuario, $post = NULL)
	{
		$date = new Zend_Date();
		
		if($post)
		{
			$post = "[ post ]";
		}
		
		$data = $date->get(Zend_Date::DAY) . "/" . $date->get(Zend_Date::MONTH) . "/" . $date->get(Zend_Date::YEAR) . " " . $date->get(Zend_Date::HOUR) . ":" . $date->get(Zend_Date::MINUTE);		
		$file = "public/log/$usuario.log";
		$tx  = "$data : $txt $post\n";
		
		if($txt && $usuario)
		{
			if(file_exists($file))
			{
				$fp = fopen($file, "a");
			}
			else
			{
				$fp = fopen($file, "x");
			}		

			fwrite($fp, $tx);

			fclose($fp);
		}
	}
}

?>